Methods
(static) makeSplitBy(stringOrRegex) → {function}
- Source:
- Since:
- 0.1.0
- See:
Return a function expecting a string to be split using the provided separator or regex
Example
> splitByDoubleDot = makeSplitBy('..')
> splitByDoubleDot('aa...a..a.a.aa.....aa..')
> ['aa', '.a', 'a.a.aa', '', '.aa', '']
Parameters:
Name | Type | Description |
---|---|---|
stringOrRegex |
stringOrRegex | Separator or regex |
Returns:
- String -> Array
- Type
- function
(static) makeSplitStringBy(string) → {function}
- Source:
- Since:
- 0.1.0
Return a function expecting a separator or regex to split the provided string
Example
> splitStringBy = makeSplitStringBy('a.b-c,d:e')
> splitStringBy(':')
['a.b-c,d', 'e']
> splitStringBy('-')
['a.b', 'c,d:e']
Parameters:
Name | Type | Description |
---|---|---|
string |
string | String to split |
Returns:
- String -> Array
- Type
- function
(static) makeTrimmedSplitBy(separator) → {function}
- Source:
- Since:
- 0.19.0
- See:
Return a function that splits the expected string and trims all the elements of the returned array
Example
> trimSplitByDoubleDot = makeTrimmedSplitBy('..')
>
> trimSplitByDoubleDot(' aa ..\ta\n..a')
['aa', 'a', 'a']
>
> trimSplitByDoubleDot(' aa ...\na..a.a.aa\n.....\taa..\n')
['aa', '.\na', 'a.a.aa', '', '.\taa', '']
Parameters:
Name | Type | Description |
---|---|---|
separator |
string |
Returns:
- String -> Array
- Type
- function